package com.gqz.aircraftwar.mvp.model.bullet

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.graphics.Matrix
import com.gqz.aircraftwar.App
import com.gqz.aircraftwar.R
import com.gqz.aircraftwar.util.BmpCache

/**
 * 加农炮
 *
 * @author gqz
 * @data 2020/4/13
 */
class CannonBullet(x: Float = 0f, y: Float = 0f) : Bullet(x, y) {

    init {
        bmp = BmpCache.loadBmp(resId)
        bmp = Bitmap.createScaledBitmap(
            bmp, (bmp.width.toFloat() * 2f).toInt(),
            (bmp.height * 2f).toInt(), false
        )
    }

    override fun draw(canvas: Canvas) {
        if (special) {
            var m = Matrix()
            m.postRotate(2f)
            m.postTranslate(x, y)
            canvas.drawBitmap(bmp, m, App.paint)
        } else
            super.draw(canvas)
    }
}